package wisp.gui;

//GTGE GUI
import com.golden.gamedev.gui.*;
import com.golden.gamedev.gui.toolkit.*;

//JFC
import java.util.*;
import java.math.*;
import java.awt.Color;
import java.awt.color.*;

//wisp
import wisp.dataObjects.Skill;
import wisp.game.PlayerSprite;

public class SkillWindow extends TFloatPanel{

	private TPanel skill1;
	private TPanel skill2;
	private TPanel skill3;
	private TLabel upgradePoints;
	private int skillPoints;
	private PlayerSprite player;
	
	private TButton sk1;
	private TButton sk2;
	private TButton sk3;
	
	//SKILL Info textboxes lol public muna lahat... lazy lazy
	public TLabel sk1sname;
	public TLabel sk1sdesc;
	public TLabel sk1sLevel;
	public TLabel sk1sCost;
	public TLabel sk1sCooldown;
	
	public TLabel sk2sname;
	public TLabel sk2sdesc;
	public TLabel sk2sLevel;
	public TLabel sk2sCost;
	public TLabel sk2sCooldown;
	
	public TLabel sk3sname;
	public TLabel sk3sdesc;
	public TLabel sk3sLevel;
	public TLabel sk3sCost;
	public TLabel sk3sCooldown;
	
	public SkillWindow(PlayerSprite p){
		super("Skill Info", true, false, 205, 205, 350, 280);
		
		player = p;
		skillPoints = p.getSkillUpgradePoints();
		
		System.out.println("[" + p.getName() + "] Skill points available: " + p.getSkillUpgradePoints());
		
		skill1 = new TPanel(0,0,350,80);
		skill2 = new TPanel(0,80,350,80);
		skill3 = new TPanel(0,160,350,80);
		
		TLabel pointLabel = new TLabel("Skill Points remaining : ", 2, 240, 280, 15);
		//pointLabel.UIResource().put("Background Color", Color.RED);
		pointLabel.setVisible(true);
		
		
		upgradePoints = new TLabel(((Integer)player.getSkillUpgradePoints()).toString(), 241, 240, 38, 15);
		upgradePoints.setVisible(true);
		
		this.add(skill1);
		this.add(skill2);
		this.add(skill3);
		
		this.add(pointLabel);
		this.add(upgradePoints);
		
		//this.update();
	}
	
	public void setSkill1(String skillname, String skilldescription, int slevel, int mpcost, double cooldown){
		sk1sname = new TLabel(skillname, 4, 4, 90, 20);
		sk1sdesc = new TLabel(skilldescription, 100, 4, 200, 36);
		sk1sLevel = new TLabel("LV" + ((Integer)slevel).toString(), 100, 40, 50, 40);
		sk1sCost = new TLabel(((Integer)slevel)+"MP".toString(), 140, 40, 50, 40);
		sk1sCooldown = new TLabel(((Double)cooldown)+"sec".toString(), 220, 40, 50, 40);
		
		
		//SKILL ICON
		TPanel picture = new TPanel(4, 25, 50,50);
		//Change color to indicate if it is clickable
		picture.UIResource().put("Background Color", Color.GRAY.darker());
			//
			sk1 = new TButton("S1", 4,4,40,40){
				public void doAction(){
					//CREATE A BETTER SKILL ICON CLASS! :D
					player.increaseSkill1();
					this.update();
					//int temp = player.getSkillUpgradePoints();
					
					//player.setSkillUpgradePoints(temp--);
					
					System.out.println("[" + player.getName() + "] Skill points available: " + player.getSkillUpgradePoints());
				}
			};
			sk1.setVisible(true);
			picture.add(sk1);
		
	
		skill1.add(sk1sname);
		skill1.add(sk1sdesc);
		skill1.add(sk1sLevel);
		skill1.add(sk1sCost);
		skill1.add(sk1sCooldown);
		skill1.add(picture);
		
		skill1.setVisible(true);
		skill1.UIResource().put("Background Color", Color.GRAY.brighter().brighter());
		
		
	}
	
	public void setSkill2(String skillname, String skilldescription, int slevel, int mpcost, double cooldown){
		sk2sname = new TLabel(skillname, 4, 4, 90, 20);
		sk2sdesc = new TLabel(skilldescription, 100, 4, 200, 36);
		sk2sLevel = new TLabel("LV" + ((Integer)slevel).toString(), 100, 40, 50, 40);
		sk2sCost = new TLabel(((Integer)slevel)+"MP".toString(), 140, 40, 50, 40);
		sk2sCooldown = new TLabel(((Double)cooldown)+"sec".toString(), 220, 40, 50, 40);
		
		
		//SKILL ICON
		TPanel picture = new TPanel(4, 25, 50,50);
		//Change color to indicate if it is clickable
		picture.UIResource().put("Background Color", Color.GRAY.darker());
			//
			sk2 = new TButton("S1", 4,4,40,40){
				public void doAction(){
					//CREATE A BETTER SKILL ICON CLASS! :D
					player.increaseSkill2();
					this.update();
					//int temp = player.getSkillUpgradePoints();
					
				//	player.setSkillUpgradePoints(temp--);
					
					System.out.println("[" + player.getName() + "] Skill points available: " + player.getSkillUpgradePoints());
				}
			};
			sk2.setVisible(true);
			picture.add(sk2);
	
		skill2.add(sk2sname);
		skill2.add(sk2sdesc);
		skill2.add(sk2sLevel);
		skill2.add(sk2sCost);
		skill2.add(sk2sCooldown);
		skill2.add(picture);
		
		skill2.setVisible(true);
		skill2.UIResource().put("Background Color", Color.GRAY.brighter().brighter());
		
		
	}
	
	public void setSkill3(String skillname, String skilldescription, int slevel, int mpcost, double cooldown){
		sk3sname = new TLabel(skillname, 4, 4, 90, 20);
		sk3sdesc = new TLabel(skilldescription, 100, 4, 200, 36);
		sk3sLevel = new TLabel("LV" + ((Integer)slevel).toString(), 100, 40, 50, 40);
		sk3sCost = new TLabel(((Integer)slevel)+"MP".toString(), 140, 40, 50, 40);
		sk3sCooldown = new TLabel(((Double)cooldown)+"sec".toString(), 220, 40, 50, 40);
		
		
		//SKILL ICON
		TPanel picture = new TPanel(4, 25, 50,50);
		//Change color to indicate if it is clickable
		picture.UIResource().put("Background Color", Color.GRAY.darker());
			//
			sk3 = new TButton("S1", 4,4,40,40){
				public void doAction(){
					//CREATE A BETTER SKILL ICON CLASS! :D
					player.increaseSkill3();
					this.update();
					//int temp = player.getSkillUpgradePoints();
					
					//player.setSkillUpgradePoints(temp--);
					
					System.out.println("[" + player.getName() + "] Skill points available: " + player.getSkillUpgradePoints());
				}
			};
			sk3.setVisible(true);
			picture.add(sk3);
	
		skill3.add(sk3sname);
		skill3.add(sk3sdesc);
		skill3.add(sk3sLevel);
		skill3.add(sk3sCost);
		skill3.add(sk3sCooldown);
		skill3.add(picture);
		
		skill3.setVisible(true);
		skill3.UIResource().put("Background Color", Color.GRAY.brighter().brighter());
		
		
	}
	
	public void increaseSkillPoint(){
		skillPoints++;
	}
	
	public void setSkillPoints(int s){
		skillPoints = s;
	}
	
	public int getSkillPoints(){
		return skillPoints;
	}
	
	public void update(){
		if(player.getSkillUpgradePoints() > 0)
		{
			
			if(player.get1stSkillLevel() < 10)
				sk1.setEnabled(true);
			else
				sk1.setEnabled(false);
			
			if(player.get2ndSkillLevel() < 10)
				sk2.setEnabled(true);
			else
				sk2.setEnabled(false);
			
			if(player.get3rdSkillLevel() < 10)
				sk3.setEnabled(true);
			else
				sk3.setEnabled(false);
		}
		else
		{
			sk1.setEnabled(false);
			sk2.setEnabled(false);
			sk3.setEnabled(false);
		}
		
		upgradePoints.setText(((Integer)player.getSkillUpgradePoints()).toString());
		
		//this.update();
	}
	
	public TPanel getSkill1(){
		return skill1;
	}
	
	public TPanel getSkill2(){
		return skill2;
	}
	
	public TPanel getSkill3(){
		return skill3;
	}

}
